import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';

@Entity('device_message_log')
export class Message {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: 'varchar', length: 64 })
  iot_id: string;

  @Column({ type: 'varchar', length: 64 })
  product_key: string;

  @Column({ type: 'varchar', length: 64 })
  device_name: string;

  @Column({ type: 'tinyint', width: 2, default: 0 })
  qos: number;

  @Column({ type: 'tinyint', width: 2, default: 0 })
  status: number;

  @Column({ type: 'varchar', length: 128 })
  topic_full_name: string;

  @Column({ type: 'varchar', length: 128 })
  nickname: string;

  @Column({ type: 'text' })
  message_content: string;

  @Column({ type: 'varchar', length: 64 })
  message_id: string;

  @Column({ type: 'varchar', length: 64 })
  request_id: string;

  @Column({ type: 'varchar', length: 256 })
  remark: string;

  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
  gmt_create: Date;

  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP', onUpdate: 'CURRENT_TIMESTAMP' })
  gmt_update: Date;
}
